package de.rayman2200.converter.components;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;


public class ContextMenu implements MouseListener
{

  private JPopupMenu menu = new JPopupMenu();

  private JMenuItem configure = new JMenuItem("Configure Plugins");

  private JMenuItem exit = new JMenuItem("Exit");


  public ContextMenu()
  {
    // TODO: replace the JMenuItems by Action.
    menu.add(configure);
    menu.add(exit);
  }

  public void showMenu(MouseEvent e)
  {
    menu.show(e.getComponent(), e.getX(), e.getY());
  }

  @Override
  public void mouseClicked(MouseEvent e)
  {}

  @Override
  public void mouseEntered(MouseEvent e)
  {}

  @Override
  public void mouseExited(MouseEvent e)
  {}

  @Override
  public void mousePressed(MouseEvent e)
  {
    if (e.isPopupTrigger())
    {
      showMenu(e);
    }
  }

  @Override
  public void mouseReleased(MouseEvent e)
  {
    if (e.isPopupTrigger())
    {
      showMenu(e);
    }
  }
}
